﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ControlTest
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public ObservableCollection<TreeItem> TreeItems { get; set; } = new ObservableCollection<TreeItem>();
        
        public MainWindow()
        {
            InitializeComponent();

            DataContext = this;

            TreeItems.Add(new TreeItem() { ImageName = "item 1" });
            TreeItems[0].Children.Add(new TreeItem() { ImageName = "subitem 1" });
            TreeItems[0].Children[0].Children.Add(new TreeItem() { ImageName = "level 3" });
            TreeItems[0].Children[0].Children[0].Children.Add(new TreeItem() { ImageName = "level 4" });
            TreeItems[0].Children[0].Children[0].Children.Add(new TreeItem() { ImageName = "level 4" });
            TreeItems[0].Children[0].Children.Add(new TreeItem() { ImageName = "level 3" });
            TreeItems[0].Children[0].Children.Add(new TreeItem() { ImageName = "level 3" });
            TreeItems[0].Children.Add(new TreeItem() { ImageName = "subitem 2" });
        }

        private void NumericBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
        {
            Console.WriteLine(e.Text);
        }

    }

    public class TreeItem
    {
        public ObservableCollection<TreeItem> Children { get; set; } = new ObservableCollection<TreeItem>();
        public string ImagePath { get; set; }
        public string ImageName { get; set; }
    }
}
